#!/bin/sh
#chkconfig: 2345 80 90
#description:project


path=/software/global_template
jar=/globalTemplate-1.0.0.jar
application=$path/application.yml
pid_file=/var/run/globalTemplate.pid
prod_log=/dev/null


start(){
	nohup java -jar $path$jar --spring.config.location=$application > $path/file.log 2>&1 &
	echo $! > $pid_file
	echo "success"
}

stop(){
	PID=$(cat $pid_file)
	kill -9 $PID
	echo "success"
}
status(){
	var=$(ps -ef|grep $jar |grep -v grep | wc -l);
	if [ $var != 0 ];
	then
	echo "project is running";
	else
        echo "project is not running"
        fi
}	

case "$1" in
   start)
	 start
          ;;
   stop)
         stop
	  ;;
   restart)
         stop
	 start
          ;;
   status)
 	status
	 ;;	
  *)
     echo "Usage: "$1" {start|stop|restart|status}"
     exit 1
esac

